import { createStore } from 'vuex'
import type { store, MyObj } from '../types'
import { setArr, getArr } from '../utils/localStoreage'

const store = createStore({
  state ():store {
    return {
      arr:getArr() || [
        { id:1,show: '1', number: 1 },
        { id:2,show: '2', number: 2 },
        { id:3,show: '3', number: 3 },
        { id:4,show: '4', number: 4 },
        { id:5,show: '5', number: 5 }
      ]
    }
  },
  mutations: {
    setStateArray(state:store,arr:MyObj[]) {
      state.arr = arr
      setArr(arr,'arr')
    },
}
})
export default store